import { useState } from 'react';
export const useToggle = (initStatus = false, reverseStatus = true) => {
    /** 开关状态 */
    const [state, setState] = useState(initStatus);
    /** 设置状态，默认与当前状态相反 */
    const toggle = (status = undefined) => {
        if (status)
            setState(status);
        else {
            setState(state === initStatus ? reverseStatus : initStatus);
        }
    };
    /** 设置初始状态 */
    const setInitStatus = () => setState(initStatus);
    /** 设置反转状态 */
    const setReverseStatus = () => setState(reverseStatus);
    return [state, { toggle, setInitStatus, setReverseStatus }];
};
